package com.gdones.wms.bus.car.controller;


import com.gdones.common.core.annotations.MySysLog;
import com.gdones.common.core.annotations.MySysLogOpration;
import com.gdones.common.core.dto.MyPageBand;
import com.gdones.common.core.dto.MyResult;
import com.gdones.wms.bus.car.dto.WmsCars;
import com.gdones.wms.bus.car.service.IWmsCarsService;
import com.gdones.wms.bus.inbound.dto.InboundDto;
import com.gdones.wms.bus.inbound.dto.WmsInbound;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author GaoJingBo
 * @since 2023-05-18
 */
@RestController
@RequestMapping("/car")
@Slf4j
@Api(tags = "运力管理")
public class WmsCarsController {
    
    @Resource(name = "wmsCarsServiceImpl")
    private IWmsCarsService wmsCarsServiceImpl;

    @GetMapping("/pages")
    @ApiOperation("运力管理-分页")
    @MySysLog(modelName="运力管理",methodDesc = "分页",methodType = MySysLogOpration.GET)
    public MyResult pages(WmsCars dto, MyPageBand pageBand){

        log.debug("--运力管理：分页");
        MyResult result = new MyResult();

        try {
            result = wmsCarsServiceImpl.pages(dto,pageBand);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("运力管理-分页-异常");
        }
        return result;
    }

    @GetMapping("/list")
    @ApiOperation("运力管理-列表（不分页）")
    @MySysLog(modelName="运力管理",methodDesc = "列表（不分页）",methodType = MySysLogOpration.GET)
    public MyResult list(WmsCars dto){

        log.debug("--运力管理：列表（不分页）");
        MyResult result = new MyResult();

        try {
            result = wmsCarsServiceImpl.mylist(dto);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("运力管理-列表（不分页）-异常");
        }
        return result;
    }

    @GetMapping("/getByID")
    @ApiOperation("运力管理-查询明细")
    @MySysLog(modelName="运力管理",methodDesc = "查询明细",methodType = MySysLogOpration.GET)
    public MyResult getByID(String id){

        log.debug("--运力管理：查询明细");
        MyResult result = new MyResult();

        try {
            result = wmsCarsServiceImpl.getByID(id);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("运力管理-查询明细-异常");
        }
        return result;
    }

    @PostMapping("/add")
    @ApiOperation("运力管理-添加")
    @MySysLog(modelName="运力管理",methodDesc = "添加",methodType = MySysLogOpration.POST)
    public MyResult add(@RequestBody WmsCars dto){

        log.debug("--运力管理：添加");
        MyResult result = new MyResult();

        try {
            result = wmsCarsServiceImpl.add(dto);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("运力管理-添加-异常");
        }
        return result;
    }

    @PutMapping("/update")
    @ApiOperation("运力管理-修改")
    @MySysLog(modelName="运力管理",methodDesc = "修改",methodType = MySysLogOpration.PUT)
    public MyResult update(@RequestBody WmsCars dto){

        log.debug("--运力管理：修改");
        MyResult result = new MyResult();

        try {
            result = wmsCarsServiceImpl.update(dto);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("运力管理-修改-异常");
        }
        return result;
    }

    @DeleteMapping("/deletes")
    @ApiOperation("运力管理-删除")
    @MySysLog(modelName="运力管理",methodDesc = "删除",methodType = MySysLogOpration.DELETE)
    public MyResult deletes(String ids){

        log.debug("--运力管理：删除");
        MyResult result = new MyResult();

        try {
            result = wmsCarsServiceImpl.deletes(ids);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("运力管理-删除-异常");
        }
        return result;
    }

}
